package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.AudioFrequency;
import com.juneng.mapper.AudioFrequencyMapper;
import com.juneng.service.IAudioFrequencyService;
import com.juneng.dto.AudioFrequencyDto;
import com.juneng.dto.AudioFrequencyQueryDto;
import com.juneng.vo.AudioFrequencyVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 音频表 服务实现类
 *
 * @author zds
 * @since 2021-07-14
 */
@Service
@AllArgsConstructor
public class AudioFrequencyServiceImpl implements IAudioFrequencyService {

    protected AudioFrequencyMapper audioFrequencyMapper;
    @Override
    public IPage<AudioFrequencyVo> page(AudioFrequencyQueryDto dto) {
        IPage<AudioFrequencyVo> page = Condition.getPage(dto);
        return audioFrequencyMapper.page(page,dto);
    }

    @Override
    public List<AudioFrequency> list(AudioFrequencyQueryDto dto) {
        QueryWrapper<AudioFrequency> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,AudioFrequency.class));
        return audioFrequencyMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(AudioFrequencyDto dto) {
        return audioFrequencyMapper.insert(BeanCopyUtils.copy(dto,AudioFrequency.class));
    }

    @Override
    public Integer updateById(AudioFrequencyDto dto) {
        return audioFrequencyMapper.updateById(BeanCopyUtils.copy(dto,AudioFrequency.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return audioFrequencyMapper.deleteBatchIds(toIntList);
    }

    @Override
    public AudioFrequency getById(Integer id) {
        return audioFrequencyMapper.selectById(id);
    }
}
